package com.haiyuancloud.base.ctr;

import com.haiyuancloud.base.deal.ctr.BaseCtr;
import com.haiyuancloud.base.id.service.Power4jNoService;
import com.haiyuancloud.util.ObjectUtil;
import lombok.extern.log4j.Log4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;


@Log4j
@RestController
@RequestMapping("/no/ctr")
public class NoCtr extends BaseCtr {

    @Resource
    private Power4jNoService power4jNoService;



    /***
     * 加载编号索引
     * @param submitMap 提交参数
     */
    @RequestMapping(value = "/getNo")
    @ResponseBody
    public Map<String, Object> getId(@RequestBody Map<String, Object> submitMap) {
        Map<String,Object> no = this.getDefaultResultData();
        String noKey = ObjectUtil.toString(submitMap.get("noKey"),"HY");
        no.put("no",power4jNoService.getForName(noKey));
        return no;
    }
}
